package code.c01_introduction.homework;

import com.sun.scenario.effect.impl.sw.sse.SSEBlend_SRC_OUTPeer;

import java.util.Scanner;

/**
 * @author thinkpad - 83start
 * @version v1.0
 * @create 2022/9/9 22:49
 * @package code.c01_introduction.homework
 * @description 素数判断问题
 */

public class PrimeNumber {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int x=-1 , y=-1 ;
        boolean flag = true;

        System.out.println("请输入 x y 的值，以空格隔开，每组占一行，一组占两个数字。（x = y = 0 时候结束）");
        while (x != 0 || y!= 0){
          x = scanner.nextInt();
          y = scanner.nextInt();
          if (!isPrimeNumber(x) || !isPrimeNumber(y)){
              flag =false;
          }
        }

       if (flag){
           System.out.println("OK");
       }else {
           System.out.println("SORRY");
       }
    }

    static boolean isPrimeNumber(int n){
        n = n*n + n +41;

        for (int i = 2;i<n;i++){
            if (n%i==0){//不是素数
                return false;
            }
        }
        return true;
    }
}
